package com.fyzk.activity.lottery.shuzicai;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.fyzk.base.BaseActivity;
import com.fyzk.data.preference.MySharedPreferences;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.tyjc.lottery.R;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.view.TopTitleView;

public class InfoDetailActivity extends BaseActivity implements
		onTopTitleClickListener {

	private String title = "";
	private String webId = "";

	private TopTitleView topView;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_info_detail_webview);
		getInfo();

	}

	private void getInfo() {
		Intent intent = getIntent();
		if (intent != null) {
			title = intent.getStringExtra(IntentParamUtils.TITLE);
			webId = intent.getStringExtra(IntentParamUtils.URL);
		}
		initView(title, webId);
	}

	private void initView(String title, String webId) {
		topView = (TopTitleView) findViewById(R.id.topTitle);
		topView.setRightVisible(View.GONE);
		topView.setCenterText(title);
		topView.setOnTitleClickListener(this);
		initWebView(webId);
	}

	public void initWebView(String webId) {
		WebView webView = (WebView) findViewById(R.id.ruyipackage_webview);
		String url = webId;
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setBuiltInZoomControls(true);
		webView.setWebViewClient(new WebViewClient());
		if(MySharedPreferences.getInstance().getLoginStatus()){
			webView.loadUrl(url+"?tk="+MySharedPreferences.getInstance().getAuthtoken());
		}else{
			webView.loadUrl(url);
		}

	}

	public void onPause() {
		super.onPause();
	}

	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

	@Override
	public void onLeftClick() {
		// TODO Auto-generated method stub
		finish();
	}

	@Override
	public void onCenterClick() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onRightClick() {
		// TODO Auto-generated method stub

	}
	@Override
	public void onRight2Click() {
		// TODO Auto-generated method stub
		
	}
}
